<?php
    header("Access-Control-Allow-Origin: *");
    
    include 'sessionvalid.php';
?>
<?php
    
    $username = "pocketgames_dk";
    $password = "mHiRL4bV";
    $hostname = "pocketgames.dk.mysql";
    
    
    //connection to the database
    $dbhandle = mysql_connect($hostname, $username, $password) or die("Unable to connect to MySQL");
    
    //select a database to work with
    $selected = mysql_select_db("pocketgames_dk",$dbhandle) or die("Could not select database");

    $question = mysql_real_escape_string($_POST['question']);
    $answer = mysql_real_escape_string($_POST['answer']);
    $id = $_POST['id'];
    
    $sql="UPDATE Quiz SET question='".$question."', answer='".$answer."' WHERE id='".$id."'";
    
    if (!mysql_query($sql)) {
        die('Error: ' . mysql_error($dbhandle));
    }
    
    mysql_close($dbhandle);
    
    header("Location: http://www.pocketgames.dk/quiz/ShowQuestions.php");
    
    exit;
?>